//2.统计一个文件calcCharNum.txt 中字母'A'和'a'出现的总次数
//       -----------------------开始--------------------------
//       hello everyone.
//       A apple is a fruit.
//       America is a country.
//       -----------------------结束--------------------------

package HomeWork2;

import java.io.*;

public class FileHomeWork2 {
    public static int count;
    public static void main(String[] args) {
        FileInputStream fis=null;

        try {
            fis=new FileInputStream(new File("D:\\calcCharNum.txt"));

            int x=0;
            while((x=fis.read())!=-1){
                if(x=='a'||x=='A'){
                    count=count+1;
                }
            }
            System.out.println("A和a总数："+count);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if(null!=fis){
                try{
                    fis.close();
                }catch (IOException e){
                    e.printStackTrace();
                }
            }
        }

    }
}

